package com.devunion.reader.server.mediator;

import com.devunion.bogdan.model.project.PaperInfo;
import com.devunion.reader.client.to.PaperInfoTo;

/**
 * @author Timoshenko Alexander 28.05.2009 : 11:00:39
 */
public class PaperInfoMediator implements IMediator<PaperInfo, PaperInfoTo> {
    private AuthorMediator authorMediator;

    public void setAuthorMediator(AuthorMediator authorMediator) {
        this.authorMediator = authorMediator;
    }

    public PaperInfoTo copyFromEntity(PaperInfo anEntity) {
        PaperInfoTo theTo = new PaperInfoTo();
        theTo.setCreationEndDate(anEntity.getCreationEndDate());
        theTo.setCreationExactDate(anEntity.getCreationExactDate());
        theTo.setCreationStartDate(anEntity.getCreationStartDate());
        theTo.setLanguage(anEntity.getLanguage());
        theTo.setNumberOfPages(anEntity.getNumberOfPages());
        theTo.setTitle(anEntity.getTitle());
        theTo.setType(anEntity.getType().name());
        theTo.setAuthor(authorMediator.copyFromEntity(anEntity.getAuthor()));
        return theTo;
    }
}
